<?php

namespace App\model;

use Illuminate\Database\Eloquent\Model;
use DB;

class User extends Model
{
    //
    //
	private $id;

    private $account;

    private $password;

    private $alias;

    private $identify;

    private $faculty;

    private $avatar;

    private $description;

    private $phone;

    private $stu_id;

    public function __construct($id){
    	$user = DB::table('sots_user')->select()->where(['id' => $id])->get()->toArray();

    	foreach ($user as $key => $value) {
    		$this->$key = $value;
    	}
    	return $this;
    }

    public function changeThedetail($change){
    	foreach ($change as $key => $value) {
    		if ($key == 'id') {
    			continue;
    		}
    		$this->$key = $vlaue;
    	}
    }

    public function get(){
    	foreach ($this as $key => $value) {
    		if ($key == 'id') {
    			continue;
    		}
    		$user[$key] = $value;
    	}
    	return $user;
    }

    public function saveTheChange(){
    	foreach ($this as $key => $value) {
    		if ($key == 'id') {
    			continue;
    		}
    		$user[$key] = $value;
    	}
    	$success = DB::table('sots_user')->update($user)->where(['id' => $id]);
    	return $success;
    }
}
